import { Component, OnInit } from '@angular/core';
import {CdkDragDrop, moveItemInArray,transferArrayItem} from '@angular/cdk/drag-drop';

declare var ckplayer: any;//angular 打包后json文件路会有径问题，直接在Index中src引入
@Component({
  selector: 'app-dragsort',
  templateUrl: './dragsort.component.html',
  styleUrls: ['./dragsort.component.less']
})
export class DragsortComponent implements OnInit {

  constructor() { }
  url = 'https://cz-video-view.oss-cn-beijing.aliyuncs.com/20200203/95631e413e76a2738b603f57d575e8c4.mp4'
  player:any
  ngOnInit(): void {
    this.videoPlay(this.url)
  }
  videoPlay(url?: any) {

    const videoObject = {
        container: '#video', // 绑定容器
        variable: this.player, // 初始函数
        // loop: true, // 播放结束是否循环播放
        autoplay: true, // 自动播放
        live:true,
        debug:true,
        video: url
    };
    let player = new ckplayer(videoObject);
    this.player = player

  }
  lists=[
    'red',
    'orange',
    'yellow',
    'green',
    'darkGreen',
    'blue',
    'purple',
  ]
  todo = [
    'Get to work',
    'Pick up groceries',
    'Go home',
    'Fall asleep'
  ];

  done = [
    'Get up',
    'Brush teeth',
    'Take a shower',
    'Check e-mail',
    'Walk dog'
  ];

  drop(event: CdkDragDrop<string[]>) {
    moveItemInArray(this.lists, event.previousIndex, event.currentIndex);
    console.log(event)
  }
  dropStart(event): void {
    debugger

  }
  drop2(event: CdkDragDrop<string[]>) {
    if (event.previousContainer === event.container) {
      moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
    } else {
      transferArrayItem(event.previousContainer.data,
                        event.container.data,
                        event.previousIndex,
                        event.currentIndex);
    }
  }
}
